Skip to content

Update particle builtins description in Spatial shader#11879

Open
Calinou wants to merge 1 commit into
godotengine:masterfrom
Calinou:spatial-shader-particle-builtins
Open

Update particle builtins description in Spatial shader#11879
Calinou wants to merge 1 commit into
godotengine:masterfrom
Calinou:spatial-shader-particle-builtins

Conversation

@Calinou

@Calinou Calinou commented Mar 26, 2026

Copy link
Copy Markdown
Member

If we want to merge this now, I can remove the USERDATA1 note and split it to its own PR.

PS: USERDATA1-6 aren't documented anywhere in the manual. What would be the best place to introduce it? These are only available in particle shaders.

@Calinou Calinou requested review from a team as code owners March 26, 2026 23:28
@Calinou Calinou added bug area:manual Issues and PRs related to the Manual/Tutorials section of the documentation waiting on pr merge PRs that can't be merged until an engine PR is merged first labels Mar 26, 2026
Comment thread tutorials/shaders/shader_reference/spatial_shader.rst Outdated
@paddy-exe

Copy link
Copy Markdown
Contributor

PS: USERDATA1-6 aren't documented anywhere in the manual. What would be the best place to introduce it? These are only available in particle shaders.

I would argue in the particle shader page as a separate section with a barebone example on how to read/write the values.

@Calinou Calinou force-pushed the spatial-shader-particle-builtins branch from ef795b6 to 9ba6fb1 Compare April 4, 2026 16:38
* **x**: Current rotation angle in radians.
* **y**: Time the particle has been active in seconds.
* **z**: Current animation frame.
* **w**: Particle lifetime in seconds.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. I don't know how to easily phrase it, but it contains the randomness of the lifetime.

So for example a certain particle may have 0.9 in CUSTOM.w, meaning the particle lives for 90% of the specified lifetime. So when this particle dies, CUSTOM.y will contain 0.9. Dividing Y by W gives the correct result.

I count on you all to figure out a phrasing for this, i have no idea how to make it intuitive.

@Calinou Calinou Jun 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've amended the description based on this, but I haven't tested it in-engine.

Is there a way to access the total particle lifetime in seconds? As I understand it, having access to the lifetime randomness ratio alone doesn't make it possible to figure out the total lifetime in seconds, and therefore calculate a phase from 0.0 to 1.0.

For example, with a lifetime randomness of 0.6, CUSTOM.W would be between 0.4 and 1.0 (randomly determined for each particle).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a question worth answering. Marking as unsolved to make it noticeable.

@skyace65 skyace65 added topic:shaders and removed waiting on pr merge PRs that can't be merged until an engine PR is merged first labels Apr 18, 2026
@skyace65

Copy link
Copy Markdown
Member

@Calinou Poke. Please see QbieShay's review

@mhilbrunner

Copy link
Copy Markdown
Member

Another gentle @Calinou bump :)

@Calinou Calinou force-pushed the spatial-shader-particle-builtins branch 2 times, most recently from f6a1755 to 20b9689 Compare June 11, 2026 16:23
Comment thread tutorials/shaders/shader_reference/spatial_shader.rst Outdated
Comment thread tutorials/shaders/shader_reference/spatial_shader.rst Outdated
@Calinou Calinou force-pushed the spatial-shader-particle-builtins branch from 20b9689 to 7461c74 Compare June 16, 2026 00:04

@Mickeon Mickeon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that big of a deal, but I would personally document w by itself, along with the division, because otherwise we're giving a rather vague, albeit useful instruction based on assumptions. Who knows, they could be needing that value for something else.

* **z**: Animation frame.
* **x**: Current rotation angle in radians.
* **z**: Current animation frame.
* **y / w** (division): Lifetime fraction from 0.0 to 1.0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm.

Suggested change
* **y / w** (division): Lifetime fraction from 0.0 to 1.0.
* **y / w** (division): Lifetime fraction from ``0.0`` to ``1.0``.

* **x**: Current rotation angle in radians.
* **y**: Time the particle has been active in seconds.
* **z**: Current animation frame.
* **w**: Particle lifetime in seconds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a question worth answering. Marking as unsolved to make it noticeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:manual Issues and PRs related to the Manual/Tutorials section of the documentation bug topic:shaders

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants